package com.example.myapplication;

import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
    private Button go  ;
    private TextView t1 ;
    private TextView t2 ;
    private TextView t3 ;
    private static final String name = "MainActivity" ;
    private ImageButton wyy ;
    private ImageButton bilbil ;
    private ImageButton baidu ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout02);
        Log.e(this.name, "This is onCreate");

        t1 = (TextView)findViewById(R.id.editTextTextPersonName) ;
        t2 = (TextView)findViewById(R.id.editTextTextPersonName2) ;
        t3 = (TextView)findViewById(R.id.editTextTextPersonName4) ;
        wyy = (ImageButton) findViewById(R.id.wyy) ;
        bilbil = (ImageButton) findViewById(R.id.bilbil) ;
        baidu = (ImageButton) findViewById(R.id.baidu) ;

        go = findViewById(R.id.button) ;
        go.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,MainActivity2.class) ;
                intent.putExtra("手机号",t1.getText().toString()) ;
                intent.putExtra("验证码",t2.getText().toString()) ;
                intent.putExtra("密码",t3.getText().toString()) ;
                startActivity(intent);
            }
        });

        wyy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = getPackageManager().getLaunchIntentForPackage("com.netease.cloudmusic");
                startActivity(intent);
            }
        });

        bilbil.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = getPackageManager().getLaunchIntentForPackage("tv.danmaku.bili");
                startActivity(intent);
            }
        });

        baidu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW") ;
                intent.setData(Uri.parse("http://www.baidu.com")) ;
                startActivity(intent);
            }
        });
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.e(this.name, "This is onStart");
    }

    protected void onResume(){
        super.onResume();
        Log.e(this.name, "This is onResume");
    }

    protected void onPause(){
        super.onPause();
        Log.e(this.name, "This is onPause");
    }


    @Override
    protected void onStop() {
        super.onStop();
        Log.e(this.name, "This is onStop");
    }

    protected void onRestart(){
        super.onRestart();
        Log.e(this.name, "This is onRestart");
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e(this.name, "This is Destory");
    }
}